home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / src / GLperf3.12-src.lha / GLperf / TexCopyG.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-01  |  5.1 KB  |  160 lines

  1. /*
  2.  * (c) Copyright 1995, Silicon Graphics, Inc.
  3.  * ALL RIGHTS RESERVED
  4.  * Permission to use, copy, modify, and distribute this software for
  5.  * any purpose and without fee is hereby granted, provided that the above
  6.  * copyright notice appear in all copies and that both the copyright notice
  7.  * and this permission notice appear in supporting documentation, and that
  8.  * the name of Silicon Graphics, Inc. not be used in advertising
  9.  * or publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.
  11.  *
  12.  * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
  13.  * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
  14.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
  15.  * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
  16.  * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
  17.  * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
  18.  * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
  19.  * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
  20.  * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
  21.  * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
  22.  * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
  23.  * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
  24.  *
  25.  * US Government Users Restricted Rights
  26.  * Use, duplication, or disclosure by the Government is subject to
  27.  * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
  28.  * (c)(1)(ii) of the Rights in Technical Data and Computer Software
  29.  * clause at DFARS 252.227-7013 and/or in similar or successor
  30.  * clauses in the FAR or the DOD or NASA FAR Supplement.
  31.  * Unpublished-- rights reserved under the copyright laws of the
  32.  * United States.  Contractor/manufacturer is Silicon Graphics,
  33.  * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
  34.  *
  35.  * Author: John Spitzer, SGI Applied Engineering
  36.  *
  37.  */
  38.  
  39. #include <stdio.h>
  40. #include <stdlib.h>
  41. #include "FuncEnum.h"
  42. #ifdef WIN32
  43. #include <windows.h>
  44. #endif
  45. #include <GL/gl.h>
  46. #include <malloc.h>
  47.  
  48. /* This will be set by compile time #defines                     */
  49. /* They control the size and functionality of the code generated */
  50. #ifdef FULL_FUNCPTR_PATHS
  51.   #define FUNC_PTRS 1
  52. #else
  53.   #define FUNC_PTRS 0
  54. #endif
  55.  
  56. char* pntSuccinct[] = {
  57.     "",
  58.     "Ptr"
  59. };
  60.  
  61. char* objDrawSuccinct[] = {
  62.     "",
  63.     "Point",
  64.     "Tri"
  65. };
  66.  
  67. char* subtSuccinct[] = {
  68.     "Ta",
  69.     "Ts"
  70. };
  71.  
  72. char* PrintEntry(FILE *fp, int td, int p, int od, int subt)
  73. {
  74.     char* funcName = (char*)malloc(64);
  75.     sprintf(funcName,"TexCopy%dD%s%s%s",
  76.             td,
  77.             pntSuccinct[p], 
  78.             objDrawSuccinct[od], 
  79.             subtSuccinct[subt]
  80.            );
  81.     fprintf(fp,"#define FUNCTION %s\n", funcName);
  82.     if (p)
  83.         fprintf(fp,"#define FUNCTION_PTRS\n");
  84.     if (subt)
  85.         fprintf(fp,"#define SUBTEXTURE\n");
  86.     if (od == 1)
  87.         fprintf(fp,"#define POINT_DRAW\n");
  88.     else if (od == 2)
  89.         fprintf(fp,"#define TRI_DRAW\n");
  90.     fprintf(fp,"#define TEX_DIM %d\n", td);
  91.     fprintf(fp,"#include \"TexCopyX.c\"\n");
  92.     fprintf(fp,"#undef FUNCTION\n");
  93.     fprintf(fp,"#undef SUBTEXTURE\n");
  94.     fprintf(fp,"#undef FUNCTION_PTRS\n");
  95.     fprintf(fp,"#undef POINT_DRAW\n");
  96.     fprintf(fp,"#undef TRI_DRAW\n");
  97.     fprintf(fp,"#undef TEX_DIM\n");
  98.     fprintf(fp,"\n");
  99.     return funcName;
  100. }
  101.  
  102. #define TOTAL_FUNCS 2*2*4*4
  103.  
  104. #if defined (GL_EXT_texture3D)
  105.   #define MAX_TEX_DIM 3
  106. #else
  107.   #define MAX_TEX_DIM 2
  108. #endif
  109.  
  110. #ifdef GL_EXT_subtexture
  111.   #define SUBTEX 1
  112. #else
  113.   #define SUBTEX 0
  114. #endif
  115.  
  116. main()
  117. {
  118.     TexImageCopyFunc function;
  119.     int i;
  120.     int td, p, od, subt;
  121.     FILE *fp, *header;
  122.     char* names[TOTAL_FUNCS];
  123.  
  124.     for (i=0; i<TOTAL_FUNCS; i++)
  125.         names[i] = "Noop";
  126.     header = fopen("TexCopyX.h", "w");
  127.     fprintf(header, "/*\n * File TexCopyX.h generated from TexCopyG (source file TexCopyG.c)\n */\n\n");
  128.     fp = fopen("TexCopyF.c", "w");
  129.     fprintf(fp, "/*\n * File TexCopyF.c generated from TexCopyG (source file TexCopyG.c)\n */\n\n");
  130.     fprintf(fp, "#include \"Tex.h\"\n");
  131. #ifdef GL_EXT_copy_texture
  132.     for (td=1;td<=MAX_TEX_DIM;td++) {
  133.         for (p=0;p<=FUNC_PTRS;p++) {
  134.             for (od=0;od<3;od++) {
  135.                 for (subt=0;subt<=SUBTEX;subt++) {
  136.             if (!(td==3 && subt==0)) {
  137.                         function.word = 0;
  138.                         function.bits.texDim  = td-1;
  139.                         function.bits.functionPtrs  = p;
  140.                         function.bits.objDraw     = od;
  141.                         function.bits.subtexture    = subt;
  142.                         names[function.word] = PrintEntry(fp, td, p, od, subt);
  143.                         fprintf(header, "void %s(TestPtr);\n", names[function.word]);
  144.             }
  145.                 }
  146.             }
  147.         }
  148.     }
  149. #endif
  150.     fclose(fp);
  151.     fprintf(header, "void Noop(TestPtr);\n");
  152.     fprintf(header, "typedef void (*CopyExecuteFunc)(TestPtr);\n");
  153.     fprintf(header, "\nCopyExecuteFunc TexImageCopyExecuteTable[] = {\n");
  154.     for (i=0; i<TOTAL_FUNCS; i++)
  155.         fprintf(header, "    %s,\n", names[i]);
  156.     fprintf(header, "};\n");
  157.     fclose(header);
  158.     return 0;
  159. }
  160.